<template>
    <div class="common-layout">
        <el-container>
            <el-header>
                <div style="float: right;">
                    {{ username }}
                    <el-avatar :size="50" :src="avator" />
                    <el-dropdown placement="bottom">
                        <el-button> 个人中心 </el-button>
                        <template #dropdown>
                            <el-dropdown-menu>
                                <el-dropdown-item>个人设置</el-dropdown-item>
                                <el-dropdown-item>个人内容</el-dropdown-item>
                                <el-dropdown-item>
                                    <el-button plain @click="open">退出</el-button>
                                </el-dropdown-item>
                            </el-dropdown-menu>
                        </template>
                    </el-dropdown>
                </div>
            </el-header>
            <el-container>
                <el-aside width="200px">侧边栏</el-aside>
                <el-main>内容</el-main>
            </el-container>
        </el-container>
    </div>
</template>

<script setup>
let username = localStorage.getItem('username')
let avator = localStorage.getItem('avator')
import request from '@/request/request'
import { ElMessage, ElMessageBox } from 'element-plus'
const open = () => {
    ElMessageBox.confirm(
        '您确定要退出吗?',
        'Warning',
        {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
        }
    )
        .then(() => {
            ElMessage({
                type: 'success',
                message: '退出成功',
            })
            request.post('/quit').then(res=>{
                if(res.data.code==10000){
                    
                }
            })
        })
        .catch(() => {
            ElMessage({
                type: 'info',
                message: '退出失败',
            })
        })
}
</script>

<style lang="scss" scoped></style>